package cn.com.ourclass.webviewnew;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

import com.hc.framework.log.LogUtils;

import java.util.ArrayList;

import cn.com.ourclass.webviewnew.wb.WebViewActivity;
import cn.com.ourclass.webviewnew.web.tools.PhotoSelectActivity;

public class MainActivity extends AppCompatActivity {

    public static final int REQUEST_CAMERA_CODE = 10;
    public static final int REQUEST_PREVIEW_CODE = 20;
    public static final int REQUEST_PHOTO_CODE = 30;
    private Context mContext = this;
    private ArrayList<String> images = new ArrayList<>();

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // full screen
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.activity_main);

        Button btn = (Button)findViewById(R.id.testBtn);

        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //WebViewNewActivity.loadUrl(mContext,"http://192.168.3.124/Hk/index/index/hid/1000009/uid/3231","");
                //WebViewActivity.loadUrl(mContext,"http://192.168.3.124/Hk/index/index/hid/1000009/uid/3231","");
                cn.com.ourclass.webviewnew.wb.WebViewActivity.loadUrl(mContext,"http://192.168.0.128/Hk/index/index/hid/1000009/uid/3231",true,"");
                //com.hc.framework.web.WebViewActivity.loadUrl(mContext,"http://192.168.0.128/Hk/index/index/hid/1000009/uid/3231",true,false);
            }
        });

        Button pic = (Button)findViewById(R.id.pic);

        pic.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, PhotoSelectActivity.class);
                //startActivityForResult(intent, -1);
                startActivityForResult(intent, REQUEST_PHOTO_CODE);

            }
        });


    }

    // 为了获取结果
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(resultCode == RESULT_OK) {
            switch (requestCode) {
                case REQUEST_PHOTO_CODE:
                    String result = data.getStringExtra("result");
                    LogUtils.e(result);
                    break;
            }
        }
    }
}
